<?php
// +----------------------------------------------------------------------
// | 海豚PHP框架 [ DolphinPHP ]
// +----------------------------------------------------------------------
// | 版权所有 2016~2017 河源市卓锐科技有限公司 [ http://www.zrthink.com ]
// +----------------------------------------------------------------------
// | 官方网站: http://dolphinphp.com
// +----------------------------------------------------------------------
// | 开源协议 ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------

namespace app\goods\model;

use think\Model;

/**
 * 编码规则
 */
class CodeRule extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = '__GOODS_CODERULE__';

    // 自动写入时间戳
    protected $autoWriteTimestamp = true;

    public static function codeselect($map = [], $order = ''){
    	$data_list = self::where($map)->order($order)->paginate();
    	foreach ($data_list as $key => $value) {
    		switch ($value['codevalue2']) {
    			case '1':
    				$value['codevalue2'] = '款自编码';
    				break;
    			case '2':
    				$value['codevalue2'] = '颜色自编码';
    				break;
    			case '3':
    				$value['codevalue2'] = '尺码自编码';
    				break;
    			case '4':
    				$value['codevalue2'] = '款货号';
    				break;
    			case '5':
    				$value['codevalue2'] = '颜色名称';
    				break;
    			case '6':
    				$value['codevalue2'] = '尺码名称';
    				break;
    		}
 
	    	switch ($value['codevalue4']) {
	    			case '1':
	    				$value['codevalue4'] = '款自编码';
	    				break;
	    			case '2':
	    				$value['codevalue4'] = '颜色自编码';
	    				break;
	    			case '3':
	    				$value['codevalue4'] = '尺码自编码';
	    				break;
	    			case '4':
    					$value['codevalue4'] = '款货号';
    				break;
    			case '5':
    				$value['codevalue2'] = '颜色名称';
    				break;
    			case '6':
    				$value['codevalue2'] = '尺码名称';
    				break;
	    		}
	    	switch ($value['codevalue6']) {
	    			case '1':
	    				$value['codevalue6'] = '款自编码';
	    				break;
	    			case '2':
	    				$value['codevalue6'] = '颜色自编码';
	    				break;
	    			case '3':
	    				$value['codevalue6'] = '尺码自编码';
	    				break;
	    			case '4':
    					$value['codevalue6'] = '款货号';
    				break;
    			case '5':
    				$value['codevalue2'] = '颜色名称';
    				break;
    			case '6':
    				$value['codevalue2'] = '尺码名称';
    				break;
	    		}
	    	$data_list[$key]['rule'] = $value['codevalue1'].$value['codevalue2'].$value['codevalue3'].$value['codevalue4'].$value['codevalue5'].$value['codevalue6'].$value['codevalue1'];
	    }

	    return $data_list;
    }			

    
}